/**
 * Created by ${PRODUCT_NAME}.
 * User: skylerparr
 * Date: 12/11/10
 * Time: 11:22 PM
 * To change this template use File | Settings | File Templates.
 */
package com.thoughtorigin.application {
import com.thoughtorigin.util.ClassCreator;

import flash.utils.getDefinitionByName;

public class ObjectFactory {
    public function ObjectFactory() {
    }

    public static function create(clazz: Class, args: Array): Object {
        try {
            return Framework.inject(clazz, args);
        } catch(e: Error) {
            //todo: display error message
        }
        return null;
    }

    public static function createFromName(name : String, args: Array): Object {
        return create(Class(getDefinitionByName(name)), args);
    }
}
}
